<?php

use Base\AdminController;
use JetBrains\PhpStorm\NoReturn;

class ResourcesController extends AdminController
{
	protected string $table = "resources";

    protected string $model = "resource";

	#[NoReturn] public function init(): void
    {
		if (Request::input("type")) {
            $this->where[] = ['type',Request::input("type")];
        }
		if (Request::input("title")) {
            $this->where[] = ['title','like', '%'.Request::input("title").'%'];
        }
        $this->routeWhiteLst = ['resources@dashboard'];
        parent::init();
    }

    #[NoReturn] public function dashboardAction(): void
    {
        $data = ResourceModel::query()->whereIn("type",['1,3'])->limit(5)->get();
        $this->apiSuccess($data->toArray(),"获取成功",20000);
    }
}
